
<%@ page import="pc.system.*,wstrader.*,wstrader.task.*" %>

<%
    Users user = Trader.getUser(request.getParameter("uid"));
	
	if (user == null || !user.Authenticated()) {
		response.sendRedirect("logon.jsp");	
		return;
	}
	
	wstrader.task.reference.MasterList task = user.reference.master_list;
	
	((Tasks)task.getOwner()).clearFocus();
	task.setFocus(true);
	//task.forwardToChild(user.getuid());		
%>

<%@include file="header.jsp"%>

<%
	long focused_id = task.doTask();
	if (focused_id <= 0) focused_id = 1;
	//String master_table = task.getMasterTable();
	//String master_field = task.getMasterField();
	//long new_id = task.getLastID(master_table);
%>

<link href="style.css" rel="stylesheet" type="text/css">
<script language="javascript">

function doAddNew(id)
{
	if (id == null) id = "master_list_value";
	var value = "New Value";
	if (addNewListItemById(id,value) < 0) return;
	//
	//setText("id",<%//=new_id%>);

	setValue("name","");
	setValue("description","");
	setValue("address","");
	setValue("email","");
	setValue("telephone","");
	setValue("fax","");
	setValue("hand_phone","");
	setValue("title","");
	setValue("country_code","");
	setCbxById("buyer_",0);
	setCbxById("seller_",0);
	setCbxById("shipper_",0);
	setCbxById("agent_",0);
	setCbxById("client_",0);
	setCbxById("broker_",0);
	//
	setCbxById("active_",1);
	setFieldFocus(value);
}

function doDelete(id)
{
	if (id == null) id = "master_list_value";
	var s = "Are you sure to delete item: " + getSelectedText(id) + " (" + getSelectedValue(id) + ")";
	if (confirm(s) == 1) {
		doTask(2);
	}	
}
</script>

<form method="POST" name="formMain" action="" onSubmit="">				  
    <table width="100%" border="0">
      <tr valign="top">
	  	<td width="150">&nbsp;</td>
        <td width="860" align="left"><img src="images/master-list.jpg" width="108" height="19"></td>
      </tr>
    </table>
    <table width="100%" border="0">
      <tr valign="top" bgcolor="#EEEEEE">
	  	<td width="150" align="center" class="style1"> Master List</td>
	  	<td id="value_col_1" width="200" align="center" class="style1">Value</td>
        <td align="center"><strong class="style1">Detail</strong></td>
      </tr>
      <tr valign="top">
	  	<td>
		<select name="master_list" size=22 class="style2" id="master_list" style="width:100%;" onChange="doPost()">
		  <option value="origin_master">Origin Master</option>
		  <option value="quality_master">Quality Mater</option>
		  <option value="grade_master">Grade Master</option>
		  <option value="warehouse_master">Warehouse Master</option>
		  <option value="region_master">Regions</option>
		  <option value="country_master">Countries</option>
  		  <option value="city_master">Destination</option>        
		  <option value="company_master">Company Master</option>
		  <option value="contact_person_master">Contact Person</option>
		  <option value="contract_term_master">Contract Terms</option>
		  <option value="packing_master">Packing</option> 
		  <option value="arbitration_master">Arbitrations</option>
		  <option value="payment_term_master">Payment Terms</option>
  		  <option value="futures_account_master">Futures Account</option>
        </select>		
		</td>
		<%task.getResponse().setSelected("master_list",task.getMasterListId());%>
	  	<td id="value_col_2">
			<select name="master_list_value" id="master_list_value" size="22" class="style2" style="width:100%" onChange="doPost()">
				<%task.getResponse().setOption(task.getMasterList());%>
				<%task.getResponse().setSelected("master_list_value",focused_id);%>
    	  	</select>		
		</td>
<%
	Record rc = task.getMasterRef();
%>				
        <td align="center" valign="center"><table id="tab_" width="100%" border="1" cellpadding="0" cellspacing="0">
		  <tr>
			  <td height="334" align="center"><%@include file="reference.master-list.update.jsp"%></td>
		  </tr>
		</table></td>
	<script language="javascript">
		setCbx(getObj("active_"),<%=rc.getIntValue("active")%>);
	</script>
<%
	rc.close();
%>		
      </tr>
	  <tr id="value_row_1" style="display: ">
	  	<td>&nbsp;</td>
	  	<td id="value_col_3" valign="middle"><img src="images/new.gif" width="15" height="15" onClick="doAddNew()">&nbsp;<img src="images/delete.gif" width="15" height="15" onClick="doDelete()"></td>
	  	<td align="left" valign="middle"><img src="images/update.gif" width="15" height="15" onClick="doTask(1)"></td>
	  </tr>
    </table>
	<input type="hidden" name="uid"        id="uid"        value="<%=user.getuid()%>">		
    <input type="hidden" name="task_id"    id ="task_id"   value="0">
	<input type="hidden" name="active"     id="active"     value="1">
</form>  

<script language="javascript">
</script>
<%@include file="../footer.jsp"%>

